package com.lxh.lxhcrm.model.pojos;

import javax.persistence.*;
import java.sql.Date;
import java.util.Objects;

/**
 * 采购抬头表
 */
@Entity
public class Caigou {
    private int caiId;          //采购表id
    private String caiDan;      //采购单单号
    private Date deliveryDate;  //交货日期
    private String addDel;      //备注
    private Integer state;      //状态

    private Emp emp;
    private AppCai appCai;
    private PayWey payWey;              //支付方式
    private DeliveryType deliveryType;  //交货方式
    private InvoiceType invoiceType;    //发票类别
    private AppointPay appointPay;      //付款约定

    @ManyToOne
    @JoinColumn(name = "delivery_id")
    public DeliveryType getDeliveryType() {
        return deliveryType;
    }

    public void setDeliveryType(DeliveryType deliveryType) {
        this.deliveryType = deliveryType;
    }

    @ManyToOne
    @JoinColumn(name="pay_id")
    public PayWey getPayWey() {
        return payWey;
    }

    public void setPayWey(PayWey payWey) {
        this.payWey = payWey;
    }

    @ManyToOne
    @JoinColumn(name = "invoice_id")
    public InvoiceType getInvoiceType() {
        return invoiceType;
    }

    public void setInvoiceType(InvoiceType invoiceType) {
        this.invoiceType = invoiceType;
    }

    @ManyToOne
    @JoinColumn(name = "appoint_id")
    public AppointPay getAppointPay() {
        return appointPay;
    }

    public void setAppointPay(AppointPay appointPay) {
        this.appointPay = appointPay;
    }

    @ManyToOne
    @JoinColumn(name = "emp_id",referencedColumnName = "emp_id")
    public Emp getEmp() {
        return emp;
    }

    public void setEmp(Emp emp) {
        this.emp = emp;
    }

    @OneToOne
    @JoinColumn(name = "app_cai_id",referencedColumnName = "app_cai_id")
    public AppCai getAppCai() {
        return appCai;
    }

    public void setAppCai(AppCai appCai) {
        this.appCai = appCai;
    }

    @Id
    @Column(name = "cai_id", nullable = false)
    public int getCaiId() {
        return caiId;
    }

    public void setCaiId(int caiId) {
        this.caiId = caiId;
    }

    @Basic
    @Column(name = "cai_dan", nullable = true, length = 40)
    public String getCaiDan() {
        return caiDan;
    }

    public void setCaiDan(String caiDan) {
        this.caiDan = caiDan;
    }

    @Basic
    @Column(name = "delivery_date", nullable = true)
    public Date getDeliveryDate() {
        return deliveryDate;
    }

    public void setDeliveryDate(Date deliveryDate) {
        this.deliveryDate = deliveryDate;
    }


    @Basic
    @Column(name = "add_del", nullable = true, length = 40)
    public String getAddDel() {
        return addDel;
    }

    public void setAddDel(String addDel) {
        this.addDel = addDel;
    }

    @Basic
    @Column(name = "state", nullable = true)
    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Caigou caigou = (Caigou) o;
        return caiId == caigou.caiId &&
                Objects.equals(caiDan, caigou.caiDan) &&
                Objects.equals(deliveryDate, caigou.deliveryDate) &&
                Objects.equals(addDel, caigou.addDel) &&
                Objects.equals(state, caigou.state) &&
                Objects.equals(emp, caigou.emp) &&
                Objects.equals(appCai, caigou.appCai) &&
                Objects.equals(payWey, caigou.payWey) &&
                Objects.equals(deliveryType, caigou.deliveryType) &&
                Objects.equals(invoiceType, caigou.invoiceType) &&
                Objects.equals(appointPay, caigou.appointPay);
    }

    @Override
    public int hashCode() {
        return Objects.hash(caiId, caiDan, deliveryDate, addDel, state, emp, appCai, payWey, deliveryType, invoiceType, appointPay);
    }
}